package io.gitee.zhangbinhub.acp.core.ftp.conf

import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement
import io.gitee.zhangbinhub.acp.core.common.base.BaseXml
import io.gitee.zhangbinhub.acp.core.common.log.LogFactory

/**
 * @author zhang by 12/07/2019
 * @since JDK 11
 */
@JacksonXmlRootElement(localName = "ftp-config")
class FtpConfig : BaseXml() {
    @JacksonXmlElementWrapper(useWrapping = false)
    @JacksonXmlProperty(localName = "listen")
    var listens: List<FtpListener>? = null

    companion object {

        private val log = LogFactory.getInstance(FtpConfig::class.java)

        @JvmStatic
        fun getInstance(): FtpConfig? =
            try {
                load(FtpConfig::class.java) as FtpConfig
            } catch (e: Exception) {
                log.error(e.message, e)
                null
            }
    }

}